import java.util.*;


class Anagram {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        boolean decision = true;

        //Read input and remove spaces
        System.out.print("Enter your first string: ");
        String wordSource = in.nextLine().replaceAll("\\s+", "");

        System.out.print("Enter your second string: ");
        String wordTarget = in.nextLine().replaceAll("\\s+", "");

        //Remove src's string characters from target one
        if (wordSource.length() == wordTarget.length()) {
            for (int i = 0; i < wordSource.length(); i++) {
                wordTarget = wordTarget.replaceFirst("[\\x" + Integer.toHexString(wordSource.codePointAt(i)) + "]", "");
            }

            //Check string
            if (!wordTarget.isEmpty()) decision = false;

        } else {
            decision = false;
        }
        System.out.println("Is string an anagram: " + decision);
    }
}